# -*- coding: utf-8 -*-
"""
Created on Thu Oct 03 11:56:08 2013

@author: jkwong
"""

# PBAR_MakeBasicScanZspecDiagnosticPlots.py
# makes basic scan plots for zspec
import numpy as np
import glob


scanNumbers = np.array((\
    4643,4647,4679,4694,4698,4703,4704,4714,4727,4729,4739,4740,4761,4763,4776,4789,4807, \
    4808,4822,4835,4839,4852,4853,4866,4871,4872,4887,4888,4904,4906,4907,4923,4924, \
    4937,4938,4939,4940,4941,4942,4954,4955,4971,4972,4974,4975,4996,4997,5012,5014, \
    5015,5035,5036,5050,5051,5074,5087,5088,5089,5106,5107,5108,5135,5144,5157,5161, \
    5163,5164,5182,5183,5199,5206,5221,5222,5240,5241,5254,5255,5269,5270,5283,5284, \
    5299,5300))

for s in scanNumbers:
    filename = glob.glob(r'%d/*.npy' %s)
    print(filename[0])
    dat = np.load(filename[0])
    dat2 = dat.sum(axis = 1)
    newfilename = filename[0].replace('.npy', '_Collapsed.npy')
    newfilename = r'npy' + newfilename[4:]
    print(newfilename)
    np.save(newfilename, dat2)
    
    